<template>
  <el-dialog v-if="visible"
             :title="title"
             :visible.sync="visible"
             :width="dialogWidth"
             :close-on-click-modal="false"
             top="20vh">
    <component :is="component.name"
               ref="component"
               :disabled="disabled"
               v-bind="component"
               @cancel="handleCancel"
               @confirm="handleConfirm" />
  </el-dialog>
</template>
<script>
import { DialogRegistrar } from "@tablra"
import CustomerDescriptions from "@basic/CustomerDescriptions.vue"
import ConsigneeDescriptions from "@basic/ConsigneeDescriptions.vue"
import DriverDescriptions from "@basic/DriverDescriptions.vue"
import VehicleDescriptions from "@basic/VehicleDescriptions.vue"
import GoodsDescriptions from "@basic/GoodsDescriptions.vue"
import ShippingAddressDefaults from "./ShippingAddressDefaults.vue"
import QuickDispatch from "./QuickDispatch.vue"
import BatchDispatch from "./BatchDispatch.vue"
import QuickReceipt from "./QuickReceipt.vue"
import BatchReceipt from "./BatchReceipt.vue"
import OrderRemark from "./OrderRemark.vue"
import OrderReceipt from "./OrderReceipt.vue"
import CustomSettingsComponent from "./SettingsContainer.vue"
import BillEntry from "./BillEntry.vue"
import RmsDetail from "./RmsDetail.vue"
import RemarkSubmit from "./RemarkSubmit.vue"
import ReasonSubmit from "./ReasonSubmit.vue"
import OrderDeviceBind from "./OrderDeviceBind.vue"
import WaybillDeviceBind from "./WaybillDeviceBind.vue"
import TrackBatchBind from "./TrackBatchBind.vue"
import DivideRouters from "./DivideRouters.vue"
import ContractClose from "./ContractClose.vue"
import ContractQuotationType from "./ContractQuotationType.vue"
import Record from "./Record.vue"
import OrderBatchReceipt from "./OrderBatchReceipt.vue"
import BigDataApproveSubmit from "./BigDataApproveSubmit.vue"
import BigDataJoinSubmit from "./BigDataJoinSubmit.vue"
import SplitWaybill from "./SplitWaybill.vue"
import QuotationSendClosed from "./QuotationSendClosed.vue"
import DriverDispatchDialog from "./DriverDispatchDialog.vue"
import BatchReject from "./BatchReject.vue"

export default {
  name: "TableDialogSet",
  components: {
    ConsigneeDescriptions,
    CustomerDescriptions,
    DriverDescriptions,
    VehicleDescriptions,
    GoodsDescriptions,
    ShippingAddressDefaults,
    CustomSettingsComponent,
    QuickDispatch,
    BatchDispatch,
    QuickReceipt,
    BatchReceipt,
    OrderReceipt,
    OrderRemark,
    OrderDeviceBind,
    WaybillDeviceBind,
    TrackBatchBind,
    BillEntry,
    RmsDetail,
    RemarkSubmit,
    ReasonSubmit,
    DivideRouters,
    ContractClose,
    ContractQuotationType,
    Record,
    OrderBatchReceipt,
    BigDataApproveSubmit,
    BigDataJoinSubmit,
    SplitWaybill,
    QuotationSendClosed,
    DriverDispatchDialog,
    BatchReject
  },
  data () {
    return {
      visible: false,
      disabled: false,
      component: {},
    }
  },
  computed: {
    title () {
      return this.component?.title || "详情";
    },
    dialogWidth () {
      return this.component?.width;
    },
  },
  created () {
    DialogRegistrar.register(this)
  },
  methods: {
    mount (component) {
      this.component = component
      this.visible = !this.visible
    },
    handleCancel () {
      this.visible = false;
    },
    handleConfirm () {
      this.visible = false;
      this.$emit("refresh");
    }
  },
}
</script>

<style scoped>
span {
  font-size: 18px;
  font-weight: 600;
  padding-left: 10px;
}
</style>